﻿#ifndef REPORTMANAGER_H
#define REPORTMANAGER_H

#include <QObject>
#include <QDateTime>
#include "wordExporter.h"
#include "excelExporter.h"
#include "DbHelper.h"

extern QMap<int, QVariantMap> expLogInfo;

class ReportManager : public QObject
{
    Q_OBJECT
private:
    ReportManager();

public:

    enum ExportType{
        WORD = 0,
        EXCEL = 1,
        CSV = 2
    };
    struct stReportInfo{
        QMap<QString, QString>  expInfo;
        QVector<QStringList>    logInfo;
    };


    static ReportManager& I();

    // 默认导出设置
    bool        setExportPath(QString path);
    bool        setExportType(ExportType type);
    bool        setAutoExport(bool state);
    // 获取默认设置
    QString     getExportPath();
    ExportType  getExportType();
    bool        isAutoExport();

    // 更新实验信息
    void        updateExperimentInfo(QMap<QString, QString> info);
    QMap<QString, QString> getExperimetnInfo();

    // 导出报告
    Q_INVOKABLE int         exportReport();                 // 自动导出
    int         exportReport(QString path);     // 指定路径导出


private:

    stReportInfo    queryReportInfo();

    QMap<QString, QString>  _expInfo;


    ExportType      _exportType = WORD;
    QString         _exportPath = "E:/";
    bool            _autoExport = true;
    QStringList     _typeSuffix = {".docx", ".xlsx", ".csv"};


};

#endif // REPORTMANAGER_H
